package com.xgst.bmg.sse.task;

import com.xgst.bmg.sse.session.SSESession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Date;

/**
 * @BelongsProject: screen-win
 * @BelongsPackage: com.xgst.bmg.sse
 * @Author: xgstjs-11
 * @CreateTime: 2021-05-18 14:08:05
 * @Description: SSE心跳任务
 */
public class SSEHeartBeatTask implements Runnable {
    private static final Logger logger = LoggerFactory.getLogger(SSEHeartBeatTask.class);

    private final String clientId;

    public SSEHeartBeatTask(String clientId) {
        this.clientId = clientId;
    }

    @Override
    public void run() {
        logger.info("MSG: SseHeartbeat | ID: {} | Date: {}", clientId, new Date());
        SSESession.send(clientId, "{\"returnType\":\"ping\"}");
    }
}
